package com.vcredit.creditcat.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.vcredit.creditcat.framework.util.Base64Util;
import com.vcredit.creditcat.service.GetWebApiFromRC;
import com.vcredit.creditcat.vo.RcParamVo;

@Controller
@RequestMapping("/rc")
public class RcController {
	@Autowired
	private GetWebApiFromRC webapi;
	private String callFrom = "CreditFlower";

	@ResponseBody
	@RequestMapping("/getWsdlResult")
	public String getWsdlResult(@RequestBody RcParamVo param) {
		String result = "";
		try {
			result = webapi.getRCWebServiceSoap().getRuleResultByCustomWithIdentityNoCallFrom(callFrom,
					param.getIdentityNo(), param.getCustName(), param.getModelname(),
					Base64Util.base64Decode(param.getXmldatasource()));

			// JAXBContext context =
			// JAXBContext.newInstance(RcResultResponse.class);
			// Unmarshaller unmarshaller = context.createUnmarshaller();
			// response = (RcResultResponse) unmarshaller.unmarshal(new
			// StringReader(result));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

}
